﻿namespace IceCS.DesignPattern.Core.InterpreterPattern.PersonExpression
{
    public class AndExpression : IExpression
    {
        private readonly IExpression _expression1;
        private readonly IExpression _expression2;

        /// <summary>Initializes a new instance of the <see cref="T:System.Object"></see> class.</summary>
        public AndExpression(IExpression expression1, IExpression expression2)
        {
            _expression1 = expression1;
            _expression2 = expression2;
        }

        /// <summary>
        /// 解释
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool Interpret(string context)
        {
            return _expression1.Interpret(context) && _expression2.Interpret(context);
        }
    }
}
